<?php

/**
* Set value to the float type if it's not empty
* 
*/
class Products_Filter_Double implements Zend_Filter_Interface 
{
    
    /**
     * Defined by Zend_Filter_Interface
     *
     * Returns the string $value, removing all but digit characters
     *
     * @param  string $value
     * @return string
     */
    public function filter($value)
    {
        switch(true)
        {
            case 0 == $value : 
                return $value;
            case strlen($value) : 
                return (float)str_replace(',', '.', $value);
            default : 
                return $value;
        }
    }
    
}